package com.nip.irregularvebsdict.services;

import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import com.nip.irregularvebsdict.widgets.WidgetUtilities;

public class IrregularVerbsHandle extends Handler {

	private Service service;
	
	Bundle bundle;
	Intent intent;

	public IrregularVerbsHandle(Service service) {
		super();
		this.service = service;
		bundle = new Bundle();
		intent = new Intent();
	}
	@Override
	public void handleMessage(Message msg) {

		if (msg.what == ServicesUtilities.ACTION_UPDATE) {
			intent = new Intent(WidgetUtilities.WIDGET_UPDATE_TIME_ACTION);
			bundle = new Bundle();
			bundle.putSerializable(ServicesUtilities.UPDATE_TIME_KEY,
					ServicesUtilities.getDateTime());
			intent.putExtras(bundle);
			service.sendBroadcast(intent);
		}else if(msg.what == ServicesUtilities.ACTION_UPDATE_WORD)
		{
			intent = new Intent(WidgetUtilities.WIDGET_UPDATE_WORD_ACTION);
			service.sendBroadcast(intent);
		}

		super.handleMessage(msg);
	}

	
}
